﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;

namespace Nova_DAL
{
    public class Page
    {
        DataSet ds = null;
        string strSQL = "";
        Nova_DAL.DbHelper dbHelper = new DbHelper();
        DbCommand cmd = null;

        public DataSet PageDatasource(Nova_MOD.Page page)
        {
            try
            {
                strSQL = "exec Sp_Paged_Datasource @tblName,@fldName,@PageSize,@PageIndex,@IsReCount,@OrderType,@strWhere";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                dbHelper.AddInParameter(cmd, "@tblName", DbType.String, page.tblName);
                dbHelper.AddInParameter(cmd, "@fldName", DbType.String, page.fldName);
                dbHelper.AddInParameter(cmd, "@PageSize", DbType.Int32, page.PageSize);
                dbHelper.AddInParameter(cmd, "@PageIndex", DbType.Int32, page.PageIndex);
                dbHelper.AddInParameter(cmd, "@IsReCount", DbType.Boolean, page.IsReCount);
                dbHelper.AddInParameter(cmd, "@OrderType", DbType.Boolean, page.OrderType);
                dbHelper.AddInParameter(cmd, "@strWhere", DbType.String, page.strWhere);
                ds = dbHelper.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }
    }
}
